let jwt = require('jsonwebtoken');

module.exports = {
  sign: ({username,_id}) =>  jwt.sign({username,_id}, '2105', {expiresIn: 60 * 60 * 24}),
  verify: token => new Promise((resolve,reject)=>{
    jwt.verify(token, '2105', (err,decode)=>{
      if(!err){
        resolve(decode);// {username,_id}
      }else{
        reject(err.message)
      }

    })
  })
}